home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
6_1.lha
/
6_1
/
6_1c.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-08
|
440b
|
19 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
/ exercise 6.1
/ string "add to end" operator
tring& string::operator+=(string& st2)
char *s1 = p->s;
char *s2 = st2.p->s;
int s1len = strlen(s1);
char *ns = new char[s1len + strlen(s2) + 1];
strcpy(ns, s1);
strcpy(ns + s1len, s2);
delete s1;
p->s = ns;
return *this;